<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<html>
<base href="<%=basePath%>">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>众筹管理后台</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/toastr.css" />
<link rel="stylesheet" href="css/dashboard.css" />
</head>
<body>
	<nav class="navbar navbar-inverse navbar-fixed-top">
		<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed"
					data-toggle="collapse" data-target="#navbar" aria-expanded="false"
					aria-controls="navbar">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="#">众筹管理平台</a>
			</div>
			<div id="navbar" class="navbar-collapse collapse">

				<ul class="nav navbar-nav navbar-right">
					<li><a href="index.do">首页</a></li>
					<li><a href="javascript:void(0)">欢迎,
							${login_admin.adminRealname }</a></li>
					<li><a href="admin/quit.do" title="退出登录">退出</a></li>
				</ul>
			</div>
		</div>
	</nav>

	<div class="container-fluid">
		<div class="row">
			<div class="col-sm-3 col-md-2 sidebar">
				<ul class="nav nav-sidebar">
					<li><a href="index.do">首页</a></li>
				</ul>
				<ul class="nav nav-sidebar">
					<li><a href="project/queryAll.do">所有项目</a></li>
					<li><a href="project/queryByType.do">项目审核</a></li>
					<li><a href="javascript:void(0)">项目跟踪</a></li>
					<li><a href="comment/queryAll.do">项目评论</a></li>
					<li><a href="classify/queryAll.do">项目分类</a></li>
					<li><a href="javascript:void(0)">项目推荐</a></li>
				</ul>
				<ul class="nav nav-sidebar">
					<li><a href="user/queryAll.do">注册用户</a></li>
					<li><a href="javascript:void(0)">用户资金</a></li>
					<li><a href="log.do">用户日志</a></li>
					<li><a href="user/queryByRole.do">实名审核</a></li>
				</ul>
				<ul class="nav nav-sidebar">
					<li><a href="javascript:void(0)">新闻管理</a></li>
					<li><a href="problem/queryAll.do">问题管理</a></li>
					<li class="active"><a href="admin/queryAll.do">管理用户</a></li>
					<li><a href="managelog.do">管理日志</a></li>
				</ul>
			</div>
			<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">

					<div class="panel panel-default"></div>

				<div class="panel panel-default">
					<div class="panel-heading">
						<div class="panel-title">所有管理员列表</div>
					</div>
					<div class="panel-body">

						<div class="table-responsive ">
							<div class="panel-heading">
								<div class="panel-title">
									<a class="btn btn-primary" href="javascritp:void(0)"
								onclick="add(${login_admin.adminStatus },${login_admin.adminPower })">添加一个管理员</a>
								</div>
							</div>
					<table class="table table-striped table-bordered">
						<thead>
							<tr>
								<th>管理员序号</th>
								<th>管理员姓名</th>
								<th>管理员用戶名</th>
								<th>管理员密码</th>
								<th>管理员等级</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${p.list }" var="list_admin">
								<tr>
									<td>${list_admin.adminId }</td>
									<td>${list_admin.adminRealname }</td>
									<td>${list_admin.adminName }</td>
									<td>******</td>
									<td><c:if test="${list_admin.adminPower==0 }">老板</c:if> <c:if
											test="${list_admin.adminPower==1 }">总经理</c:if> <c:if
											test="${list_admin.adminPower==2 }">超管</c:if> <c:if
											test="${list_admin.adminPower==3 }">管理员</c:if></td>
									<td><a href="javascritp:void(0)"
										onclick="delete_admin(${login_admin.adminStatus },${list_admin.adminId },${login_admin.adminId },${login_admin.adminPower },${list_admin.adminPower })">删除</a>
									</td>
								</tr>
							</c:forEach>


						</tbody>
					</table>
				</div>

				<nav aria-label="Page navigation" class="text-center">
					<ul class="pagination">
						<li><a href="admin/queryAll.do?tr=${p.prePage }"
							aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
						</a></li>
						<li><span aria-hidden="true">${p.pageNum }/${p.pages }页</span></li>
						<c:if test="${p.pageNum<p.pages }">
						<li><a href="admin/queryAll.do?tr=${p.nextPage }"
							aria-label="Next"> <span aria-hidden="true">&raquo;</span>
						</a></li>
						</c:if>
					</ul>
				</nav>
			</div>


		</div>

	</div>
	</div>
	</div>

	<script type="text/javascript" src="js/jquery1.12.4.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/countUp.js"></script>
	<script type="text/javascript" src="js/toastr.js"></script>
	<script>
			
			function add(a_stastu,a_power){
				if(a_stastu ==0){
					if(a_power>1){
						toastr.error("你的权限不够");
					}else{
						setTimeout("window.location.href='add_admin.do'",1)
					}
				}else{
					toastr.error("你的权限不够");
				}
			}
			
			function delete_admin(a_stastu,del_id,a_id,a_power,del_power){
				if(a_stastu ==0 ){
					if(a_power>2){
						toastr.error("你的权限不够");
					}else{
						if(del_power<=a_power){
							toastr.error("你的权限不够");
						}else{
							$.ajax({
								url:"admin/delAdmin.do",
								type:"post",
								data:{"a_id":del_id},
								success:function(data){
									toastr.info(data);
									setTimeout("window.location.href='admin/queryAll.do'",500)
								},
								error:function(){toastr.error("服务端错误");}
							})
						}
					}
				}else{
					toastr.error("你的权限不够");
				}
				
			}
			
			
		</script>


</body>
</html>